package exam.ccwtest;

import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;

public class c07_OptionMenu extends Activity {
	public void onCreate (Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		TextView MyText = new TextView(this);
		MyText.setText("메뉴키를 누르세요.");
		setContentView(MyText);
	}
	
	public boolean onCreateOptionsMenu (Menu menu) {
		super.onCreateOptionsMenu(menu);
		MenuItem item=menu.add(0, 1, 0, "짜장");
		item.setIcon(R.drawable.icon);
		item.setAlphabeticShortcut('a');
		menu.add(0, 2, 0, "짬뽕").setIcon(R.drawable.icon);
		SubMenu etc = menu.addSubMenu("기타");
		etc.add(0, 3, 0, "우동");
		etc.add(0, 4, 0, "만두");
		
		return true;
	}	// onCreateOptionsMenu end
	
	public boolean onOptionsItemSelected (MenuItem item) {
		switch (item.getItemId()) {
		case 1:
			Toast.makeText(this, "짜장은 저렴하다", Toast.LENGTH_SHORT).show();
			return true;
		case 2:
			Toast.makeText(this, "짬뽕은 약간 비싸다.", Toast.LENGTH_SHORT).show();
			return true;
		case 3:
			Toast.makeText(this, "우동은 짜다.", Toast.LENGTH_SHORT).show();
			return true;
		case 4:
			Toast.makeText(this, "만두는 서비스", Toast.LENGTH_SHORT).show();
			return true;
		}
		return false;
	}
}























